<cfparam default="0" name="url.action">
<cfcontent reset="yes">
<cfswitch expression="#url.action#">

<cfcase value="delete_resumes">
<cfquery name="get" datasource="#session.dsn#"  >
select * from resume_directory
where resume_id = #id#
</cfquery>

<cffile action="delete" file="#Session.file_path#repository\#get.resume_title#" >

<cfquery datasource="#session.dsn#" name="delete">
delete from resume_directory where resume_id = #id#
</cfquery>

</cfcase>

<cfcase value="get_resumes">
<cfquery datasource="#session.dsn#" name="search_results" >
select * from resume_directory where poc_id = #id#
</cfquery>
<cfset result_message = ''>
	<cfset result_message = '{"files":['>
	
	<cfloop query="search_results">
		<cfset result_message =  result_message & '{"resume_id":"' & Session.helpers.add_json_escapement(search_results.resume_id) & '","poc_id":"' & Session.helpers.add_json_escapement(search_results.poc_id) & '","resume_title":"' & Session.helpers.add_json_escapement(search_results.resume_title) & '","resume_image":"' & Session.helpers.add_json_escapement(search_results.resume_image) & '","resume_location":"' & Session.helpers.add_json_escapement(search_results.resume_location) & '"},'>
	</cfloop>
	<cfset result_message = Session.helpers.remove_comma_from_end_of_string(result_message)>
	<cfset result_message = result_message & ']}'>
<cfcontent type="text/html" reset="yes"><cfoutput>#result_message#</cfoutput>
</cfcase>


<cfcase value="get_sub">
<cfinvoke component="components.data" method="get_5_star_area_sub" returnvariable="search_results" id="#id#">
<cfset result_message = ''>
	<cfset result_message = '{"area":['>
	<cfloop query="search_results">
		<cfset result_message =  result_message & '{"sub_id":"' & Session.helpers.add_json_escapement(search_results.five_star_area_id) & '","sub_area":"' & Session.helpers.add_json_escapement(search_results.area)  & '","parent_id":"' & Session.helpers.add_json_escapement(search_results.five_star_area_category_id)  & '"},'>
	</cfloop>
	<cfset result_message = Session.helpers.remove_comma_from_end_of_string(result_message)>
	<cfset result_message = result_message & ']}'>
<cfcontent type="text/html" reset="yes"><cfoutput>#result_message#</cfoutput>
</cfcase>

<cfcase value="add_sub">

<cfinvoke component="components.data" method="get_sub_area" returnvariable="search_results" id="#id#">
<cfset result_message = ''>

	<cfset result_message = '{"area":['>
	<cfloop query="search_results">
		<cfset result_message =  result_message & '{"sub_id":"' & Session.helpers.add_json_escapement(search_results.five_star_area_id) & '","sub_area":"' & Session.helpers.add_json_escapement(search_results.area)  & '","parent_id":"' & Session.helpers.add_json_escapement(search_results.five_star_area_category_id)  & '","parea":"' & Session.helpers.add_json_escapement(session.queries.fiveStarArea(search_results.five_star_area_category_id))  & '"},'>
	</cfloop>
	<cfset result_message = Session.helpers.remove_comma_from_end_of_string(result_message)>
	<cfset result_message = result_message & ']}'>
<cfcontent type="text/html" reset="yes"><cfoutput>#result_message#</cfoutput>
</cfcase>

<cfcase value="make_list">
<cfset result_message = ''>
	<cfset result_message = '{"area":['>
<cfif sid_list neq "">
	<cfloop list="#sid_list#" index="i">
	<cftry>
	<cfset search_results = session.queries.fiveStarSubArea(i)>
		<cfset result_message =  result_message & '{"sub_id":"' & Session.helpers.add_json_escapement(search_results.five_star_area_id) 
		& '","sub_area":"' & Session.helpers.add_json_escapement(search_results.area)  
		& '","parent_id":"' & Session.helpers.add_json_escapement(search_results.five_star_area_category_id) 
		& '","parent_id_list":"' & Session.helpers.add_json_escapement(session.queries.MakListID(search_results.five_star_area_category_id,sid_list))
		& '","parea":"' & Session.helpers.add_json_escapement(session.queries.fiveStarArea(search_results.five_star_area_category_id)) 
		& '","sub_list":"' & Session.helpers.add_json_escapement(sub_area_list) & '"},'>
		<cfcatch type="any">
		</cfcatch>
		</cftry>
	</cfloop>
	<cfset result_message = Session.helpers.remove_comma_from_end_of_string(result_message)>
	<cfset result_message = result_message & ']}'>
<cfelse>
		<cfset result_message =  result_message & '{"sub_id":"' & Session.helpers.add_json_escapement() 
		& '","sub_area":"' & Session.helpers.add_json_escapement()  
		& '","parent_id":"' & Session.helpers.add_json_escapement() 
		& '","parent_id_list":"' & Session.helpers.add_json_escapement()
		& '","parea":"' & Session.helpers.add_json_escapement() 
		& '","sub_list":"' & Session.helpers.add_json_escapement() & '"}'>
	<cfset result_message = result_message & ']}'>
</cfif>
<cfcontent type="text/html" reset="yes"><cfoutput>#result_message#</cfoutput>
</cfcase>

<cfcase value="delete_list">
<cfparam default="0" name="slist">

<cfloop from="1" to="#listlen(sub_list)#" index="i">
<cfset num = listFindNoCase(sub_list,id)>
<cfif num neq 0>
<cfset slist = ListDeleteAt(sub_list,num)>
</cfif>

</cfloop>

<cfset salist = session.queries.get_sub_areaList(slist)>

<cfset result_message = ''>

<cfset result_message = '{"area":['>
<cfset result_message = result_message & '{"sub_area_list":"' & Session.helpers.add_json_escapement(salist) & '","deleted_pid":"' & Session.helpers.add_json_escapement(parent_id) &  '","sub_list":"' & Session.helpers.add_json_escapement(slist)  & '"},'>
<cfset result_message = Session.helpers.remove_comma_from_end_of_string(result_message)>
<cfset result_message = result_message & ']}'>
<cfcontent type="text/html" reset="yes"><cfoutput>#result_message#</cfoutput>


</cfcase>

</cfswitch>